package com.ysd.modules.app.controller;

import java.util.HashMap;
import java.util.Map;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.common.utils.R;
import com.ysd.modules.app.entity.StudentEntity;
import com.ysd.modules.app.service.StudentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/app/student")
@Api("APP学生接口")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/getStudent")
    @ApiOperation("根据学生id查询学生信息")
    public R getStudent(Integer stuId) {
        StudentEntity student = studentService.getStudentById(stuId);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "success");
        map.put("data", student);
        return R.ok(map);
    }

    @GetMapping("updateStudent")
    @ApiOperation("选择课程(记录当前正在学习的课程)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stuId", value = "学生ID", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "cid", value = "课程ID", paramType = "query", dataType = "int"),
    })
    public R updateStudent(Integer stuId, Integer cid) {
        StudentEntity studentEntity = studentService.updateStudent(stuId, cid);
        return R.ok().put("studentEntity", studentEntity);
    }

}
